<template>
	<view>
		<view class="body">
			<view class="title" v-if="list.length > 0">打包记录<text>(仅保存24小时)</text></view>
			<view class="list" v-for="(item,index) in list" :key="index">
				<view class="s_title">{{item.title}}</view>
				<view class="s_title text">
					<text>时间范围：</text><text>{{item.time_text}}</text>
				</view>
				<view class="s_title text">
					<text>创建时间：</text><text>{{item.createtime_text}}</text>
				</view>
				<view class="s_title text p-b-3" v-if="item.status == 2">
					<text>{{item.type_text}}</text>
					<text class="botton open-file" @tap="ope(index,'openfile')" v-if="item.type != 2">打开文件</text>
					<text class="botton" @tap="ope(index,'copy')" >复制下载地址</text>
				</view>
				<view class="s_title text p-b-3" v-else>
					<text>{{item.type_text}}</text>
					<text class="botton" v-if="item.status == 0" @tap="showError(index)">排队创建中...</text>
					<text class="botton" v-if="item.status == 1">正在创建...</text>
					<text class="botton" v-if="item.status == -1" @tap="showError(index)">创建失败，点击查看原因</text>
				</view>
			</view>
			<view class="show-nomore" v-if="showNoMore == true">没有更多内容了</view>
			<view class="zhanwei"></view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list:[],
				showNoMore:false,
				s_id:0
			}
		},
		onLoad(params){
			if(params.s_id)
			{
				this.s_id = params.s_id;
			}
			this.excelList();
		},
		onPullDownRefresh(){
			this.list = [];
			this.excelList();
			uni.stopPullDownRefresh()
		},
		methods: {
			showError(index){
				var info = this.list[index];
				var text = '';
				switch(info.status)
				{
					case 0:
						text = '系统正在依次创建文件，请耐心等待';
						break;
					case -1:
						text = info.status_text?info.status_text:'请联系“我的->人工客服”进行处理';
						break;
				}
				if(text)
				{
					this.$api.showModal(text,'','',{
						hideCancel:true
					});
				}
			},
			ope(index,type)
			{
				var info = this.list[index];
				switch(type){
					case 'openfile':
						this.$api.openFile(info.file_path);
						break;
					case 'copy':
						this.$api.copyText(info.file_path);
						break;
				}
			},
			excelList(){
				var that = this;
				that.$http.post('statistics/excelList',{
					s_id:that.s_id
				}).then(res=>{
					that.list = res.data.list;
					that.showNoMore = (that.list.length > 0)?false:true;
				})
			}
		}
	}
</script>

<style lang="scss">
	.body{
		background: #ffffff;
		border-radius: 20rpx;
		width: 94%;
		margin: 20rpx;
		padding: 0rpx 20rpx ;
		.list{
			border-bottom: 2rpx solid #eeeeee;
			position: relative;
			height: 270rpx;
			.s_title{
				padding: 15rpx 0;
			}
			.text{
				font-size: 26rpx;
				color: #999999;
			}
			.botton{
				display: inline-block;
				margin-right: 20rpx;
				padding: 10rpx 20rpx;
				font-size: 24rpx;
				position: absolute;
				right: 0;
				bottom: 12rpx;
				border-radius: 50rpx;
				color: $uni-btn-color;
				border:2rpx solid  $uni-btn-color;
			}
			.open-file{
				right:210rpx;
				color: #888888;
				border: 2rpx solid #888888;
			}
			.p-b-3{
				padding-bottom: 22rpx;
			}
		}
		
		.title{
			height: 80rpx;
			font-size: 30rpx;
			font-weight: 600;
			line-height: 80rpx;
			border-bottom: 2rpx solid #eeeeee;
			text{
				font-size: 24rpx;
				color: #999999;
				font-weight: normal;
				margin-left: 20rpx;
			}
		}
	}
</style>
